package com.bear.sgg.springboot_03_yaml.entity;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import java.util.List;
import java.util.Map;

/**
 * @ClassNmae Person
 * @Description TODO
 * @Author bear
 * @Date 2020/3/4 0004 下午 7:08
 */
/*
* @Component：组件注解：表示该类的实例交由spring容器管理
* @ConfigurationProperties：配置内容：表示将配置文件中的配置值映射到该类的实例中（实例必须托管到spring容器中）
*   prefix=""属性：表示需要在配置文件中进行映射的对象名称
* @Validated：校验注解：表示对该类中的属性的值进行格式校验
* */
@Component
@ConfigurationProperties(prefix = "student")
@Validated
public class StudentWithDefaultProperties {

    private String name;
    private int age;
    private String address;
    private boolean isMan;

    /*校验是否为邮箱格式，如果不是则报错*/
    @Email
    private String email;

    private Map<String, Object> map;
    private List<Object> list;

    private PetWithValue mPet;

    @Override
    public String toString() {
        return "StudentWithDefaultProperties{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", address='" + address + '\'' +
                ", isMan=" + isMan +
                ", email='" + email + '\'' +
                ", map=" + map +
                ", list=" + list +
                ", mPet=" + mPet +
                '}';
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public boolean isMan() {
        return isMan;
    }

    public void setMan(boolean man) {
        isMan = man;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public List<Object> getList() {
        return list;
    }

    public void setList(List<Object> list) {
        this.list = list;
    }

    public PetWithValue getmPet() {
        return mPet;
    }

    public void setmPet(PetWithValue mPet) {
        this.mPet = mPet;
    }
}
